﻿CREATE PROCEDURE [dbo].[yaf_message_list](
                @MessageID INT)
AS
    BEGIN
        SELECT a.MessageID,
               a.UserID,
               UserName = b.Name,
               a.Message,
               c.TopicID,
               c.ForumID,
               c.Topic,
               c.Priority,
               a.Flags,
               c.UserID                           AS TopicOwnerID,
               Edited = Isnull(a.Edited,a.Posted)
        FROM   yaf_Message a,
               yaf_User b,
               yaf_Topic c
        WHERE  a.MessageID = @MessageID
        AND b.UserID = a.UserID
        AND c.TopicID = a.TopicID
    END


